package com.jcfy.project.module.service.impl;

import java.util.List;
import com.jcfy.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.jcfy.project.module.mapper.TShopCarMapper;
import com.jcfy.project.module.domain.TShopCar;
import com.jcfy.project.module.service.ITShopCarService;

/**
 * 购物车Service业务层处理
 *
 * @author jiangfeng
 * @date 2020-08-05
 */
@Service
public class TShopCarServiceImpl implements ITShopCarService {
    @Autowired
    private TShopCarMapper tShopCarMapper;

    /**
     * 查询购物车
     *
     * @param carId 购物车ID
     * @return 购物车
     */
    @Override
    public TShopCar selectTShopCarById(Long carId) {
        return tShopCarMapper.selectTShopCarById(carId);
    }

    /**
     * 查询购物车列表
     *
     * @param tShopCar 购物车
     * @return 购物车
     */
    @Override
    public List<TShopCar> selectTShopCarList(TShopCar tShopCar) {
        return tShopCarMapper.selectTShopCarList(tShopCar);
    }

    /**
     * 新增购物车
     *
     * @param tShopCar 购物车
     * @return 结果
     */
    @Override
    public int insertTShopCar(TShopCar tShopCar) {
        tShopCar.setCreateTime(DateUtils.getNowDate());
        return tShopCarMapper.insertTShopCar(tShopCar);
    }

    /**
     * 修改购物车
     *
     * @param tShopCar 购物车
     * @return 结果
     */
    @Override
    public int updateTShopCar(TShopCar tShopCar) {
        tShopCar.setUpdateTime(DateUtils.getNowDate());
        return tShopCarMapper.updateTShopCar(tShopCar);
    }

    /**
     * 批量删除购物车
     *
     * @param carIds 需要删除的购物车ID
     * @return 结果
     */
    @Override
    public int deleteTShopCarByIds(Long[] carIds) {
        return tShopCarMapper.deleteTShopCarByIds(carIds);
    }

    /**
     * 删除购物车信息
     *
     * @param carId 购物车ID
     * @return 结果
     */
    @Override
    public int deleteTShopCarById(Long carId) {
        return tShopCarMapper.deleteTShopCarById(carId);
    }
}
